package edu.nf.takeoutdemo.web.user;

import edu.nf.takeoutdemo.commons.base.BaseController;
import edu.nf.takeoutdemo.commons.constant.StatusConstant;
import edu.nf.takeoutdemo.commons.result.Result;
import edu.nf.takeoutdemo.model.entity.Dish;
import edu.nf.takeoutdemo.model.vo.DishVO;
import edu.nf.takeoutdemo.service.DishService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 * @author zjl
 * @date 2025/10/28
 */
@RestController("userDishController")
@Slf4j
@RequestMapping("/user/dish")
@RequiredArgsConstructor
public class DishController extends BaseController {
    private final DishService dishService;

    @GetMapping("/list")
    public Result<List<DishVO>> list(Long categoryId) {
        Dish dish = new Dish();
        dish.setCategoryId(categoryId);
        dish.setStatus(StatusConstant.ENABLE);
        List<DishVO> dishVOList = dishService.listWithFlavor(dish);
        return success(dishVOList);
    }

    @GetMapping("/{id}")
    public Result<DishVO> getDish(@PathVariable("id") Long id){
        DishVO dishVO = dishService.getDish(id);
        return success(dishVO);
    }
}
